package com.hanamaki.generic;

import java.util.Arrays;
import java.util.List;

/**
 * @author hanamaki
 * @version 1.0
 * @date 2021/6/29 15:30
 */
// 泛型类
public class StudentVo<T> {

    private T id;
    private T name;
    private T[] hobbies;
    private List<T> courses;

//    属性 私有之后 要实现 对应的 get set方法
//    alt + insert

    public T getId() {
        return id;
    }

    public void setId(T id) {
        this.id = id;
    }

    public T getName() {
        return name;
    }

    public void setName(T name) {
        this.name = name;
    }

    public T[] getHobbies() {
        return hobbies;
    }

    public void setHobbies(T[] hobbies) {
        this.hobbies = hobbies;
    }

    public List<T> getCourses() {
        return courses;
    }

    public void setCourses(List<T> courses) {
        this.courses = courses;
    }


//     打印方法

    @Override
    public String toString() {
        return "StudentVo{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", hobbies=" + Arrays.toString(hobbies) +
                ", courses=" + courses +
                '}';
    }
}


class Test {

    public static void main(String[] args) {

        StudentVo zs = new StudentVo();
//         再没有 转换为 泛型类的时候 ，只能给 id 传递整型
//        zs.setId(1);

        zs.setId("");
        zs.setId(1);
        zs.setId(true);
        zs.setId(1.2);
        List<String> list = null;
        List<Double> list1 = null;
        zs.setCourses(list);
        zs.setCourses(list1);



    }

}
